#include <iostream>
#include <map>
#include <numeric>
#include <string>
using namespace std;

double weighted_value(const pair<string, double> &a, const pair<string, double> &b)
{
    return a.second * b.second;
}

int main()
{
    map<string, double> dow_price =
        {
            {"MMM", 81.86},
            {"AA", 34.69},
            {"MO", 54.45}};
    map<string, string> dow_name =
        {
            {"MMM", "3M CO."},
            {"AA", "Alcoa Inc."},
            {"MO", "Altria Group Inc."}};
    map<string, double> dow_weight =
        {
            {"MMM", 5.8549},
            {"AA", 2.4808},
            {"MO", 3.8940}};
    for (const auto &p : dow_price)
    {
        const string &symbol = p.first;
        cout << symbol << '\t' << p.second << '\t' << dow_name[symbol] << endl;
    }
    double dji_index = inner_product(dow_price.begin(), dow_price.end(), dow_weight.begin(), 0.0, plus<double>(), weighted_value);
    cout << "DJI value " << dji_index << '\n';
    return 0;
}